package com.baosight.scaq.common.aq.cInterface;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baosight.iplat4j.core.spring.SpringApplicationContext;
import com.baosight.iplat4j.dao.Dao;
import com.baosight.scaq.aq.domain.ZM04;

/**
 * <p>Title: OrgEmp.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 张小飞
 * @version 1.0
 * <pre>Histroy:
 *          2011-4-7 下午03:14:52  张小飞  Create
 *</pre>
 */
public class OrgEmp {
	
	private static Dao dao = (Dao)SpringApplicationContext.getBean("dao");
	
	/**
	 * <p>Function: getOrgCodeByEmpCode</p>
	 * <p>Description: 根据员工编号获取其所在部门编号</p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-4-7下午03:19:10 张小飞
	 * </p>
	 *
	 */
	@SuppressWarnings("unchecked")
	public static String getOrgCodeByEmpCode(String empCode){
		ZM04 zm04 = new ZM04();
		
		if(empCode==null || empCode.equals("")) {
			return zm04.getOrgCode();
		}
		else {
			empCode = empCode.trim();
		}
		
		Map<String, String> _map = new HashMap<String, String>();
		_map.put("userId", empCode);
		List<ZM04> _list = new ArrayList<ZM04>();
		
		try {
			_list = dao.query("ZM04.query", _map);
		} catch (Exception e) {
			
		}
		
		if(_list.size() < 1) {
			return zm04.getOrgCode();
		}
		else {
			zm04 = _list.get(0);
		}
		return zm04.getOrgCode();
	}
	/**
	 * 
	 * <p>Function: getEmpNameById</p>
	 * <p>Description:获取名称 </p>
	 * <p>return value:List<Map></p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-5-31下午06:41:28 余虎
	 * </p>
	 *
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public static List<Map> getEmpNames(){
		List<Map> _list = new ArrayList<Map>();
		try {
			_list = dao.query("ZM03.queryInterface", null);
		} catch (Exception e) {

		}
		return _list;
	}
}
